package com.example.rabbitmq;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author: 扎马斯
 * @date: 2024年08月29日 09:38
 * @describe: 广播模式
 */
@Configuration
public class RabbitMqFanout {

    @Bean
    public Queue createQueue1() {
        return QueueBuilder.durable(RabbitMqConf.QUEUE_FANOUT).maxLength(1000).build();
    }

    @Bean
    public Queue createQueue2() {
        return QueueBuilder.durable(RabbitMqConf.QUEUE_FANOUT_2).maxLength(1000).build();
    }

    @Bean
    public FanoutExchange createExchange1() {
        return ExchangeBuilder.fanoutExchange(RabbitMqConf.EXCHANGE_FANOUT).build();
    }

    @Bean
    public Binding fanoutBinging(@Qualifier("createQueue1") Queue createQueue1, FanoutExchange fanoutExchange) {
        return BindingBuilder.bind(createQueue1).to(fanoutExchange);
    }

    @Bean
    public Binding fanoutBinging1(@Qualifier("createQueue2") Queue createQueue2, FanoutExchange fanoutExchange) {
        return BindingBuilder.bind(createQueue2).to(fanoutExchange);
    }

}
